$(function () {
    new Typed($('.zddz')[0], {
        // 注意：输出的可以是标签，将标签当节点运行。比如下面的h2
        strings: [' 织蝶云<i>轻量级协作</i>办公平台.', '全新研发 <i>PM+OA+CRM</i> 一站式管理.', '高性能 <i>云端应用</i> 服务.', '全面助力企业 <i>提高协作效率...</i>'],
        typeSpeed: 80 // 速度
    });

    // 底部搜索
    // 获取滚动条超出范围
    function getScroll() {
        return {
            left: window.document.body.scrollLeft || window.document.documentElement.scrollLeft || window.pageXOffset || 0,
            top: window.document.body.scrollTop || window.document.documentElement.scrollTop || window.pageYOffset || 0
        };
    }
    //获取需要滚动的高度    这里需要改一下
    let num = $('.banner')[0].offsetHeight + $('.service')[0].offsetHeight + $('.introduce')[0].offsetHeight + $('.pwerfu')[0].offsetHeight + $('.started')[0].offsetHeight * 2
    // 介绍
    let num1 = $('.banner')[0].offsetHeight / 2
    // 介绍二
    let num2 = $('.banner')[0].offsetHeight + $('.service')[0].offsetHeight
    // 头条
    let num3 = $('.banner')[0].offsetHeight + $('.service')[0].offsetHeight + $('.introduce')[0].offsetHeight
    //共赢
    let num4 = $('.banner')[0].offsetHeight + $('.service')[0].offsetHeight + $('.introduce')[0].offsetHeight + $('.middle_page')[0].offsetHeight + 20
    let flag = true
    //   滚动事件
    window.onscroll = function () {
        if (getScroll().top >= num) {
            // jquery动画
            $('.started_title h1').animate({
                top: 0,
                opacity: 1
            }, 1200, function () {
                $('.started_title p').animate({
                    top: 0,
                    opacity: 1
                }, 800, function () {
                    $('.started_search form').animate({
                        top: 0,
                        opacity: 1
                    }, 600)
                })
            })
        }
        if (getScroll().top >= num1) {
            $('.js-gotop').animate({
                opacity: 1,
                right: 0
            }, 1000)
            $('.introduce_left_top').animate({
                opacity: 1,
                top: 0
            }, 1000, function () {
                $('.introduce_left_img').animate({
                    opacity: 1,
                    left: -150
                }, 800, function () {
                    $('.introduce_left_js li').animate({
                        opacity: 1,
                        left: 0
                    }, 600, function () {
                        $('.introduce_right li').animate({
                            opacity: 1,
                            right: 0
                        }, 300)
                    })
                })
            })
            if (flag) {
                let nub = setTimeout(function () {
                    //    86
                    let numB1 = 25
                    let numb1 = setInterval(() => {
                        $('.num1').text(++numB1)
                        if (numB1 == 86) {
                            clearInterval(numb1)
                        }
                    }, (4000 / 62));
                    // 20
                    let numB2 = 1
                    let numb2 = setInterval(() => {
                        $('.num2').text(++numB2)
                        if (numB2 == 20) {
                            clearInterval(numb2)
                        }
                    }, (4000 / 20));
                    // 96
                    let numB3 = 36
                    let numb3 = setInterval(() => {
                        $('.num3').text(++numB3)
                        if (numB3 == 96) {
                            clearInterval(numb3)
                        }
                    }, (4000 / 61));
                    // 10000
                    let numB4 = 45
                    let numb4 = setInterval(() => {
                        $('.num4').text(++numB4 + '00')
                        if (numB4 == 100) {
                            clearInterval(numb4)
                        }
                    }, (4000 / 56));
                }, 2700, function () {
                    clearTimeout(nub)
                })
                flag = false
            }
        }
        if (getScroll().top >= num2) {
            $('.pwerfu_top').animate({
                top: 0,
                opacity: 1
            }, 2000)
        }
        if (getScroll().top >= num3) {
            $('.top-head').animate({
                top: 0,
                opacity: 1
            }, 2000)
        }
        if (getScroll().top >= num4) {
            $('.testimonial_top').animate({
                top: 0,
                opacity: 1
            }, 2000)
        }
    }

    // 返回顶部
    $("#btn").click(function () {
        $("html,body").animate({ scrollTop: 0 }, 1000)
    })

})